package InterfaceExample;

import java.util.ArrayList;

public class printOperatorlmpl2 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Stu> students) {
        int count1 = 0, count2 = 0;
        System.out.println("------------全部信息如下------------");
        for (Stu student : students) {
            if (student.getSex() == 'm')
                count1 ++;
            else
                count2 ++;
            System.out.println("姓名：" + student.getName() + "，性别："+ student.getSex() + "，成绩：" + student.getScore());
        }
        System.out.println("男生有" + count1 + "人，女生有" + count2 + "人");
        System.out.println("----------------------------------");
    }

    @Override
    public void printArgScore(ArrayList<Stu> students) {
        double allScore = 0;
        double maxScore = -1, minScore = 200;
        for (Stu student : students) {
            double score = student.getScore();
            allScore += score;
            if (score > maxScore)
                maxScore = score;
            if (score < minScore)
                minScore = score;
        }
        System.out.println("去除最高最低分的平均分：" + (allScore - maxScore - minScore) / (students.size() - 2));
    }
}
